/*
 * Copyright 2020 wangruiCoder owner
 */

package org.disk.frame.logger.client;

import org.disk.frame.logger.config.DiskFrameLoggerConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 根据{@link DiskFrameLoggerConfiguration#getClientType()}来实例化一个日志客户端用于消费日志
 * <p>日志客户端实例化工具</p>
 *
 * @author kyrie 2021/4/30 4:38 下午
 * @since jdk1.8
 * @see LogClient
 */
public class InvokeLogClient {
    private final Logger logger = LoggerFactory.getLogger(InvokeLogClient.class);

    public LogClient getClient(DiskFrameLoggerConfiguration diskFrameLoggerConfig) throws Exception {
        LogClient logClient = null;
        switch (diskFrameLoggerConfig.getClientType()){
            case REDIS:
                logClient = new RedisLogClient();
                logger.info("redis log client invoke success");
                break;
            case RABBITMQ:
                throw new Exception("unsupported log client rabbitmq");
            case KAFKA:
                throw new Exception("unsupported log client kafka");
        }
        return logClient;
    }
}
